package com.cskaoyan.config;

import com.cskaoyan.interceptor.CustomHandlerInterceptor1;
import com.cskaoyan.interceptor.CustomHandlerInterceptor2;
import com.cskaoyan.interceptor.CustomHandlerInterceptor3;
import com.cskaoyan.interceptor.CustomHandlerInterceptor4;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author stone
 * @date 2022/06/22 10:12
 */
@EnableWebMvc
@ComponentScan("com.cskaoyan.controller")
public class MvcConfiguration implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //HandlerInterceptor是谁
        //HandlerInterceptor的作用范围是什么
        //HandlerInterceptor之间的顺序是什么 → 书写顺序
        registry.addInterceptor(new CustomHandlerInterceptor1()).addPathPatterns("/hello/**");
        registry.addInterceptor(new CustomHandlerInterceptor2()).addPathPatterns("/goodbye/**");
        registry.addInterceptor(new CustomHandlerInterceptor3()).addPathPatterns("/user/**");
        registry.addInterceptor(new CustomHandlerInterceptor4()).addPathPatterns("/**");
    }
}
